home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / 386bug.arc / 386BUG_A.ASM next >
Assembly Source File  |  1987-06-05  |  3KB  |  119 lines

  1.     TITLE   MULBUG - COMPAQ Computer Corporation/Microsoft Corp.
  2. ;******************************************************************************
  3. ;
  4. ;   Title:    MULBUG - 80386 32-bit MULtiply test subroutine
  5. ;
  6. ;   Module:   MULBUG
  7. ;
  8. ;   Version:  *
  9. ;
  10. ;   Date:     April 11, 1987
  11. ;
  12. ;   This subroutine provides a quick indication of the function of the 
  13. ;   32-bit MUL instruction in the Intel 80386.  
  14. ;
  15. ;   This subroutine and its source code may be freely used and copied. 
  16. ;
  17. ;******************************************************************************
  18.  
  19.  
  20. PASS    EQU    0            ; exit codes (arbitrary values)
  21. FAIL    EQU    1
  22.  
  23. OP32    MACRO
  24.     DB    66h            ; 32-bit operand override prefix
  25.     ENDM
  26.  
  27. ;    Static Name Aliases
  28. ;
  29.  
  30.     .287
  31. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  32. _TEXT    ENDS
  33. _DATA    SEGMENT     WORD PUBLIC 'DATA'
  34. _DATA    ENDS
  35. CONST    SEGMENT  WORD PUBLIC 'CONST'
  36. CONST    ENDS
  37. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  38. _BSS    ENDS
  39.  
  40. DGROUP    GROUP    CONST,    _BSS,    _DATA
  41.     ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  42.  
  43. ;------------------------------------------------------------------------------
  44. ;   Patterns for 32-bit multiply test
  45. ;
  46. _DATA    SEGMENT
  47. multiplier   DD    00000081h        ; multiplier
  48. multiplicand DD    0417A000h        ; multiplicand
  49. goodhi    DD    00000002h        ; correct product (high order)
  50. goodlo    DD    0FE7A000h        ; correct product (low order)
  51. _DATA    ENDS                ; end of segment
  52.  
  53. _TEXT    SEGMENT
  54. ;------------------------------------------------------------------------------
  55. ;   MULTEST - Check the 386 32-bit multiply instruction.
  56. ;
  57. ;   ENTRY:  (none) - C callable
  58. ;   EXIT:   AX = PASS, FAIL
  59. ;   USED:   
  60. ;   STACK:  
  61. ;
  62. _multest PROC    NEAR
  63.     PUBLIC    _multest
  64.     push    bp
  65.     mov    bp,sp
  66.         mov    cx,0000            ; 64K times is a nice round number
  67. mt_loop:
  68.         call    _mulproc        ; check the chip function
  69.         cmp    ax,FAIL            ; Q: did it work ?
  70.         je    mt_exit            ;   N: display message and exit
  71.         loop    mt_loop            ;   Y: PASSED, loop to try again
  72. mt_exit:            
  73.     mov    sp,bp
  74.     pop    bp
  75.     ret
  76. _multest ENDP
  77.  
  78. ;------------------------------------------------------------------------------
  79. ;   mulproc - 32-bit multiply pattern test.  The supplied pattern 
  80. ;   values must be used for consistent results.
  81. ;
  82. ;   ENTRY:  (none)  - C callable
  83. ;   EXIT:   EAX = PASS, FAIL
  84. ;   USED:   EAX, EBX, EDX
  85. ;   STACK:  2 bytes
  86. ;
  87. _mulproc PROC    NEAR
  88.     PUBLIC    _mulproc
  89.     OP32
  90.     mov    bx,word ptr [multiplier]
  91.                     ; mov ebx,[multiplier]
  92.     OP32
  93.     mov    ax,word ptr [multiplicand]
  94.                     ; mov eax,[multiplicand]
  95.     OP32
  96.     mul    bx            ; mul ebx
  97.  
  98.     OP32                ; Q: high order answer OK ?
  99.     cmp    dx,word ptr [goodhi]    ;    cmp edx,[goodhi]
  100.     jne    mp_fail            ;   N: exit with error
  101.     OP32                ;   Q: low order answer OK ?
  102.     cmp    ax,word ptr [goodlo]    ;    cmp eax,[goodlo]
  103.     je    mp_pass            ;     Y: good answer, exit...
  104.                     ;     N: exit with error
  105. mp_fail:
  106.     mov    ax,FAIL            ; set 'fail' return code
  107.     jmp    short mp_exit        ; and exit
  108.  
  109. mp_pass:
  110.     mov    ax,PASS            ; set 'pass' return code 
  111. ;;      jmp    short mp_exit        ; and exit
  112.  
  113. mp_exit:
  114.     ret                ; *** RETURN ***
  115. _mulproc ENDP
  116. _TEXT    ENDS
  117.  
  118.     END
  119.